package com.lanlian.commonlib.data;


import com.lanlian.commonlib.bean.BaseResponse;

import java.util.ArrayList;

/**
 * <pre>

 *     date   : 2018/8/24 19:56
 *     desc   :交易时间返回对象
 *     version: 1.0
 * </pre>
 */
public class RespTradeTime extends BaseResponse
{
     private ArrayList<TradeTimeBean> gdList;

     public String getTime(String goodsId)
     {
          String time=null;
          TradeTimeBean tb;
          for(int i=0;i<gdList.size();i++)
          {
               tb=gdList.get(i);
               if(goodsId.equals(tb.getGoodsId()+"")) {
                    if("2".equals(tb.getType()+""))
                    {
                         String[] start = tb.getBeginDate().split(",");
                         String[] end = tb.getEndDate().split(",");
//                         if (start.length == 1) {
//                              time = start[0].substring(0, 5) + "-" + end[0].substring(0, 5);
//                         } else if (start.length == 2) {
//                              time = start[0].substring(0, 5) + "-" + end[0].substring(0, 5) + "|" + start[1].substring(0, 5) + "-" + end[1].substring(0, 5);
//                              // time = start[0].substring(0, 5) + "-" + end[1].substring(0, 5);
//                         } else if(start.length == 3){
//                              time = start[0].substring(0, 5) + "-" + end[0].substring(0, 5) + "|" + start[1].substring(0, 5) + "-" + end[1].substring(0, 5)+ "|" + start[2].substring(0, 5) + "-" + end[2].substring(0, 5);
//                         }
                         for(int j=0;j<start.length;j++)
                         {
                              if(j==0)
                              {
                                   time = start[j].substring(0, 5) + "-" + end[j].substring(0, 5);
                              }
                              else
                              {
                                   time=time+"|"+start[j].substring(0, 5) + "-" + end[j].substring(0, 5);
                              }
                         }
                    }
               }
          }
          return  time;
     }


     public ArrayList<TradeTimeBean> getGdList() {
          return gdList;
     }

     public void setGdList(ArrayList<TradeTimeBean> gdList) {
          this.gdList = gdList;
     }
}
